<%--
  Created by IntelliJ IDEA.
  User: lt
  Date: 2018/2/28
  Time: 14:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro" %>
<c:set var="contextPath" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>数据统计 -- 推荐订单数据统计</title>
    <link rel="stylesheet" href="${contextPath}/static/statistics/css/bootstrap.min.css">
    <link rel="stylesheet" href="${contextPath}/static/statistics/css/bootstrap-datetimepicker.min.css">
    <link rel="stylesheet" href="${contextPath}/static/layer/css/layui.css">
    <script src="${contextPath}/static/statistics/js/jquery.js"></script>
    <script src="${contextPath}/static/statistics/js/bootstrap.min.js"></script>
    <script src="${contextPath}/static/statistics/js/bootstrap-datetimepicker.min.js"></script>
    <script src="${contextPath}/static/statistics/js/bootstrap-datetimepicker.fr.js"></script>
    <script src="${contextPath}/static/statistics/js/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="${contextPath}/static/statistics/js/bootstrap.min.js"></script>
    <script src="${contextPath}/static/statistics/js/vue.js"></script>
    <script src="${contextPath}/static/statistics/js/echarts.min.js"></script>
    <script type="text/javascript" src="${contextPath}/static/statistics/js/jquery.mockjax.js"></script>
    <script type="text/javascript" src="${contextPath}/static/statistics/js/jquery.autocomplete.js"></script>
    <style>
        .autocomplete-suggestions {
            border: 1px solid #999;
            background: #FFF;
            overflow: auto;
        }

        .autocomplete-suggestion {
            padding: 2px 5px;
            white-space: nowrap;
            overflow: hidden;
        }

        .autocomplete-selected {
            background: #F0F0F0;
        }

        .autocomplete-suggestions strong {
            font-weight: normal;
            color: #3399FF;
        }
    </style>
</head>
<body style="background: rgba(119, 118, 118, 0.15);">
<div class="container-fluid" id="app">
    <form class="form-inline" style="margin-top: 50px; margin-bottom: 5px;">
        <div class="form-group">
            <input type="text" class="form-control" id="yearMonth" placeholder="查询时间">
        </div>
        <div class="form-group">
            <input type="text" class="form-control" id="week" placeholder="查询周">
        </div>
        <button type="button" class="btn btn-success" onclick="queryOrder();">查询</button>
        <button type="button" title="根据查询条件导出所有记录" onclick="exportExcel();"
                class="btn btn-info">导出Excel
        </button>
    </form>
    <div class="row" style="background-color: rgb(53, 147, 202);margin-right: 0px;margin-left: 0px; height: 37px;">
        <div class="col-sm-10" style="margin-top: 6px;">
            <strong style="font-size: 18px;color: #f9f9f9;">订单结算情况统计</strong>
        </div>
        <div class="col-sm-2" style="text-align: right">

        </div>
    </div>
    <div class="table-responsive" id="tableContainer" style="height: 410px">
        <table class="table table-striped table-condensed table-bordered">
            <thead style="background-color:#eee;">
                <tr>
                    <th rowspan="2">区域</th>
                    <th rowspan="2">客户总数</th>
                    <th rowspan="2">推荐户数</th>
                    <th colspan="3">本月汇总</th>
                    <th colspan="3">本周汇总</th>
                </tr>
                <tr>
                    <th>推荐量汇总（条）</th>
                    <th>已购量汇总（条）</th>
                    <th>完成率</th>
                    <th>推荐量汇总（条）</th>
                    <th>已购量汇总（条）</th>
                    <th>完成率</th>
                </tr>
            </thead>
            <tbody>

            <tr v-for="(order,index) in orderList">
                <td>{{order.SUM_SHORT_NAME}}</td>
                <td>{{order.SUM_CUST_CODE}}</td>
                <td>{{order.CUST_CODE}}</td>

                <td>{{order.RECOMMEND_NUM}}</td>
                <td>{{order.CURRENT_ALREADY}}</td>
                <td>{{order.LI}}</td>

                <td>{{order.WEEK_RECOMMEND_NUM}}</td>
                <td>{{order.WEEK_CURRENT_ALREADY}}</td>
                <td>{{order.WEEK_LI}}</td>
            </tr>
            </tbody>
        </table>
    </div>
    <div style="text-align: right;margin-top: 10px;" id="pageDiv"></div>
</div>

<form action="${contextPath}/count/orderEcror" method="post" target="_blank" id="goToDetailPage"
      style="display:none">
    <input type="text" id="custCode" name="custCode" value="" style="display: none;">
    <textarea type="hidden" id="goToDetailPageData" name="rowData"></textarea>
</form>
<form action="${contextPath}/checking/exportExcel" method="post" id="exportExcel" style="display:none">
    <input type="hidden" name="tbcocompName" id="exportExcelParamTbcocompName">
    <input type="hidden" name="bankName" id="exportExcelParamBankName">
    <input type="hidden" name="merName" id="exportExcelParamMerName">
    <input type="hidden" name="settleDate" id="exportExcelParamSettleDate">
    <input type="hidden" name="payType" id="exportExcelParamPayType">
    <input type="hidden" name="tableType" value="general">
</form>
</body>
<script src=${contextPath}/static/layer/layui.all.js></script>
<script type="text/javascript">
    var laypage = layui.laypage
        , layer = layui.layer;


    var queryModel = {
        yearMonth: "",
        week: ""
    }

    var app = new Vue({
        el: '#app',
        data: {
            orderList: [],

        },
        methods: {}
    })

    var getOrder = function (queryModel) {
        console.log(queryModel);
        layer.load(1)
        $.ajax({
            url: '${contextPath}/count/getRecommendOrde', //localhost:8080
            type: 'post',
            data: queryModel,
            success: function (data) {
                layer.closeAll('loading');
                if (data.success == false) {
                    layer.msg("获取出错：" + data.message)
                    return
                }
//                console.log(data)
                var dataArray = data.data;
                if (dataArray.length == 0) {
                    layer.msg("查询没有数据")
                }
                app.orderList = dataArray
                //console.log(data.data)
            },
            error: function (error) {
                layer.closeAll('loading');
                //console.log(error)
            }
        })
    }
    getOrder(queryModel)

    var queryOrder = function () {
        queryModel.yearMonth = $("#yearMonth").val()
        queryModel.week = $("#week").val()
        getOrder(queryModel)
    }


    <%--$.ajax({--%>
    <%--url: '${contextPath}/checking/getTbcocompNamesAndBankNamesAndMerNames', //--%>
    <%--type: 'post',--%>
    <%--data: queryModel,--%>
    <%--success: function (data) {--%>
    <%--if (data.success == false) {--%>
    <%--layer.msg("获取查询条件出错，请刷新页面")--%>
    <%--return--%>
    <%--}--%>
    <%--//console.log(data)--%>
    <%--var dataObj = data.data;--%>
    <%--app.turnCreateDate = dataObj.turnCreateDate--%>
    <%--app.bindCreateDate = dataObj.bindCreateDate--%>
    <%--},--%>
    <%--error: function (error) {--%>
    <%--//console.log(error)--%>
    <%--layer.msg("获取查询条件出错，请刷新页面")--%>
    <%--}--%>
    <%--})--%>

    $('#yearMonth').datetimepicker({
        language: 'zh-CN',
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        minView: 2,
        showMeridian: 1,
        format: "yyyy-mm",
        //startDate:new Date(),
    });

    var exportExcel = function () {
        $("#exportExcelParamTbcocompName").val(queryModel.tbcocompName)
        $("#exportExcelParamBankName").val(queryModel.bankName)
        $("#exportExcelParamMerName").val(queryModel.merName)
        $("#exportExcelParamSettleDate").val(queryModel.settleDate)
        $("#exportExcelParamPayType").val(queryModel.payType)

        $("#exportExcel").submit();
    }

    //***************** 明细 ************
    function orderEcror(channelCode){
        window.location.href = "${contextPath}/count/orderEcror?custCode="+channelCode;
    }

    //*******************************


    //******************* 表头固定 *********************
    // Code goes here
    'use strict'
    window.onload = function(){
        var tableCont = document.querySelector('#tableContainer')
        /**
         * scroll handle
         * @param {event} e -- scroll event
         */
        function scrollHandle (e){
            console.log(this)
            var scrollTop = this.scrollTop;
            this.querySelector('thead').style.transform = 'translateY(' + scrollTop + 'px)';
        }

        tableCont.addEventListener('scroll',scrollHandle)
    }

    //****************************************
</script>
</html>
